package com.hzcx.app.simplechat.ui.home.dialog;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseDialog;
import com.hzcx.app.simplechat.ui.home.AddFriendFirstActivity;
import com.hzcx.app.simplechat.util.dp.DpUtils;

import butterknife.BindView;

/**
 * 首页更多弹窗
 */
public class HomeMoreDialog extends BaseDialog {
    @BindView(R.id.tv_add_friend)
    TextView tvAddFriend;
    @BindView(R.id.tv_qrcode)
    TextView tvQrcode;
    @BindView(R.id.tv_add_group)
    TextView tvAddGroup;

    private Activity activity;
    private OnHomeMoreMenuListener listener;

    public HomeMoreDialog(@NonNull Context context,OnHomeMoreMenuListener listener) {
        super(context);
        this.listener=listener;
    }

    @Override
    public int getLayout() {
        return R.layout.dialog_home_more;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {
        getWindow().setGravity(Gravity.TOP | Gravity.RIGHT);
        getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.x = DpUtils.dp2px(context, 20);
        params.y = DpUtils.dp2px(context, 40);
        getWindow().setAttributes(params);
    }

    @Override
    public void initData() {
        tvAddFriend.setOnClickListener(view -> {
            context.startActivity(new Intent(context, AddFriendFirstActivity.class));
            dismiss();
        });

        tvQrcode.setOnClickListener(view -> {
            if(listener!=null){
                listener.qrCode();
            }
            dismiss();
        });

        tvAddGroup.setOnClickListener(view -> {
            if (listener != null) {
                listener.createGroup();
            }
            dismiss();
        });
    }

    public interface OnHomeMoreMenuListener{
        void qrCode();
        void createGroup();
    }
}
